package com.smart.common.controller;

import com.p2p.common.response.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 公共异常类
 */
@ControllerAdvice//抓取异常
public class BaseExceptionHandler {
    /**
     * 全局捕获异常，如果有异常返回Result :false
     *
     * @param e
     * @return {@link Result< Object>}
     * @author jinMengLong
     * @date 2020/12/16 23:14:37
     */
    @ExceptionHandler(Exception.class)
    @ResponseBody
    public Result<Object> error(Exception e) {
        e.printStackTrace();
        return Result.FAIL(e.getMessage());
    }

}
